Skip to content

📐 added: OrthogonalCollocation with gaussradau and gausslegendre schemes#322

Merged
franckgaga merged 50 commits intomainfrom
orthogonal_colloc
Mar 3, 2026
Merged

📐 added: OrthogonalCollocation with gaussradau and gausslegendre schemes#322
franckgaga merged 50 commits intomainfrom
orthogonal_colloc

Conversation

@franckgaga
Copy link
Member

@franckgaga franckgaga commented Mar 2, 2026

The transcription method is efficient for highly stiff nonlinear systems. The default gaussradau quadrature is slightly less accurate than gausslegendre, but its an L-stable method, while the latter being A-stable.

Some comments:

  1. I default to 3 collocations points per time step/interval/finite element (for a total of 4 points, if we include the point at $\tau=0$) . I found that it's a more common default (e.g. CasADi, do-mpc, Pyomo, Gekko, etc.) than 5 points (the default of SimpleColloc.jl).
  2. I tried to write a concise documentation for details on the collocation and continuity constraints. The various references on this subject tend to be VERY verbose, but somehow succeed to skip important information like the differentiation matrix construction and how to use it. The preview of the documentation is available here : OrthogonalCollocation, the associated con_nonlinprogeq! method and init_orthocolloc.
  3. The paper "Nonlinear modeling, estimation and predictive control in APMonitor" of Hedengren et al. (2014) mention that we should factor out the final time $\tau_{n_o}$ from the differentiation matrix, to improve the numerical robustness, but no other justifications. I don't see why at all, since the condition number of the differentiation matrix is quite low (around 50 in my test case), and the matrix is already constructed on the normalized times $\tau \in [0, 1]$. I did not do this in my implementation (similarly to SimpleColloc), since it's simpler and I'm not convince that it's necessary.
  4. I only support zero order hold on the manipulated inputs for now. I will add the support of first-order hold in a following release.

Closes #238

`nc` was the number of collocation points. I renamed it to `np` since there is confusion with `mpc.con.nc`, the number of custom inequality constraints
The subscript p is already used for `Hp` i.e. "prediction".
A dispatch was not necessary for this.
It's not necessary to differentiate with a `k` vector that would include the operating point (there is never operating point in this vector). And it now follows the nomenclature of `OrthogonalCollocation`
The mutated argument is used to store the result of `model.f!` function, thus it is a derivative of the state. The distinction is more important for code readability of `CollocationMethods`.
@franckgaga franckgaga marked this pull request as draft March 2, 2026 21:27
@franckgaga franckgaga marked this pull request as ready for review March 3, 2026 00:32
@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 97.82609% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.49%. Comparing base (4ab5d3b) to head (0ac337c).
⚠️ Report is 58 commits behind head on main.

Files with missing lines Patch % Lines
src/controller/transcription.jl 97.54% 4 Missing ⚠️
src/estimator/internal_model.jl 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #322      +/-   ##
==========================================
+ Coverage   98.42%   98.49%   +0.06%     
==========================================
  Files          29       29              
  Lines        5397     5510     +113     
==========================================
+ Hits         5312     5427     +115     
+ Misses         85       83       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@franckgaga
Copy link
Member Author

franckgaga commented Mar 3, 2026

Hello @baggepinnen, I still need to implement the tests, but do you have any comments on my points above and the documentation of the new OrthogonalCollocation. The preview of the documentation is available here : OrthogonalCollocation, the associated con_nonlinprogeq! method, and init_orthocolloc.

Thanks for your time!

@baggepinnen
Copy link
Member

I no longer have the numerics details in my head, but something I do know tend to be important is numerical scaling by the "typical magnitude" of the variables. A nice benefit of these methods is that they can be made to work for DAEs relatively easily

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Benchmark Results (Julia v1)

Time benchmarks
main 0ac337c... main / 0ac337c...
CASE STUDIES/PredictiveController/CSTR/LinMPC/With feedforward/DAQP/SingleShooting 5.6 ± 0.59 ms 5.53 ± 0.42 ms 1.01 ± 0.13
CASE STUDIES/PredictiveController/CSTR/LinMPC/With feedforward/Ipopt/MultipleShooting 0.319 ± 0.0085 s 0.323 ± 0.0091 s 0.989 ± 0.038
CASE STUDIES/PredictiveController/CSTR/LinMPC/With feedforward/Ipopt/SingleShooting 0.228 ± 0.015 s 0.229 ± 0.017 s 0.996 ± 0.099
CASE STUDIES/PredictiveController/CSTR/LinMPC/With feedforward/OSQP/MultipleShooting 11.3 ± 0.6 ms 9.84 ± 0.6 ms 1.15 ± 0.093
CASE STUDIES/PredictiveController/CSTR/LinMPC/With feedforward/OSQP/SingleShooting 1.96 ± 0.073 ms 1.96 ± 0.042 ms 1 ± 0.043
CASE STUDIES/PredictiveController/CSTR/LinMPC/Without feedforward/DAQP/SingleShooting 5.57 ± 0.53 ms 5.44 ± 0.5 ms 1.02 ± 0.14
CASE STUDIES/PredictiveController/CSTR/LinMPC/Without feedforward/Ipopt/MultipleShooting 0.275 ± 0.0022 s 0.276 ± 0.0085 s 0.997 ± 0.032
CASE STUDIES/PredictiveController/CSTR/LinMPC/Without feedforward/Ipopt/SingleShooting 0.234 ± 0.0038 s 0.233 ± 0.011 s 1 ± 0.052
CASE STUDIES/PredictiveController/CSTR/LinMPC/Without feedforward/OSQP/MultipleShooting 7.77 ± 0.47 ms 6.98 ± 0.46 ms 1.11 ± 0.1
CASE STUDIES/PredictiveController/CSTR/LinMPC/Without feedforward/OSQP/SingleShooting 2.08 ± 0.068 ms 2.04 ± 0.041 ms 1.02 ± 0.039
CASE STUDIES/PredictiveController/Pendulum/LinMPC/Successive linearization/DAQP/SingleShooting 10.3 ± 1.7 ms 10.1 ± 1.6 ms 1.02 ± 0.23
CASE STUDIES/PredictiveController/Pendulum/LinMPC/Successive linearization/Ipopt/MultipleShooting 0.325 ± 0.053 s 0.33 ± 0.051 s 0.984 ± 0.22
CASE STUDIES/PredictiveController/Pendulum/LinMPC/Successive linearization/Ipopt/SingleShooting 0.159 ± 0.0019 s 0.158 ± 0.004 s 1 ± 0.028
CASE STUDIES/PredictiveController/Pendulum/LinMPC/Successive linearization/OSQP/MultipleShooting 0.097 ± 0.019 s 0.102 ± 0.021 s 0.951 ± 0.27
CASE STUDIES/PredictiveController/Pendulum/LinMPC/Successive linearization/OSQP/SingleShooting 13.7 ± 1.8 ms 13.9 ± 1.7 ms 0.982 ± 0.18
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Custom constraints/Ipopt/MultipleShooting 0.707 ± 0.041 s 0.713 ± 0.036 s 0.991 ± 0.075
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Custom constraints/Ipopt/MultipleShooting (Hessian) 0.693 ± 0.048 s 0.739 ± 0.07 s 0.938 ± 0.11
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Custom constraints/Ipopt/SingleShooting 1.75 ± 0.1 s 1.77 ± 0.13 s 0.99 ± 0.091
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Custom constraints/Ipopt/TrapezoidalCollocation 0.514 ± 0.057 s 0.525 ± 0.061 s 0.979 ± 0.16
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Custom constraints/Ipopt/TrapezoidalCollocation (Hessian) 0.512 ± 0.057 s 0.53 ± 0.06 s 0.966 ± 0.15
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Economic/Ipopt/MultipleShooting 0.355 ± 0.0072 s 0.363 ± 0.01 s 0.978 ± 0.034
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Economic/Ipopt/MultipleShooting (Hessian) 0.435 ± 0.04 s 0.441 ± 0.043 s 0.987 ± 0.13
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Economic/Ipopt/SingleShooting 0.485 ± 0.0026 s 0.497 ± 0.008 s 0.975 ± 0.016
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Economic/Ipopt/SingleShooting (Hessian) 0.167 ± 0.0024 s 0.168 ± 0.0012 s 0.998 ± 0.016
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Economic/Ipopt/TrapezoidalCollocation 0.338 ± 0.0094 s 0.344 ± 0.015 s 0.983 ± 0.051
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Economic/Ipopt/TrapezoidalCollocation (Hessian) 0.417 ± 0.045 s 0.438 ± 0.051 s 0.953 ± 0.15
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Economic/MadNLP/SingleShooting 10.1 ± 0.1 s 10.3 ± 0.25 s 0.982 ± 0.026
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/Ipopt/MultipleShooting 0.338 ± 0.0075 s 0.352 ± 0.0057 s 0.96 ± 0.026
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/Ipopt/MultipleShooting (Hessian) 0.402 ± 0.035 s 0.429 ± 0.039 s 0.936 ± 0.12
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/Ipopt/MultipleShooting (threaded) 0.369 ± 0.015 s 0.384 ± 0.014 s 0.96 ± 0.053
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/Ipopt/SingleShooting 0.5 ± 0.013 s 0.512 ± 0.021 s 0.977 ± 0.046
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/Ipopt/SingleShooting (Hessian) 0.167 ± 0.0025 s 0.171 ± 0.002 s 0.978 ± 0.019
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/Ipopt/TrapezoidalCollocation 0.33 ± 0.0044 s 0.338 ± 0.0055 s 0.975 ± 0.021
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/Ipopt/TrapezoidalCollocation (Hessian) 0.31 ± 0.019 s 0.323 ± 0.039 s 0.958 ± 0.13
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/Ipopt/TrapezoidalCollocation (threaded) 0.367 ± 0.019 s 0.382 ± 0.027 s 0.961 ± 0.084
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/MadNLP/SingleShooting 14 ± 0.37 s 14 ± 0.39 s 1 ± 0.038
CASE STUDIES/StateEstimator/CSTR/MovingHorizonEstimator/DAQP/Current form 0.039 ± 0.0013 s 0.0384 ± 0.0017 s 1.02 ± 0.057
CASE STUDIES/StateEstimator/CSTR/MovingHorizonEstimator/DAQP/Prediction form 0.0323 ± 0.0079 s 0.0319 ± 0.0078 s 1.02 ± 0.35
CASE STUDIES/StateEstimator/CSTR/MovingHorizonEstimator/Ipopt/Current form 0.179 ± 0.035 s 0.174 ± 0.042 s 1.03 ± 0.32
CASE STUDIES/StateEstimator/CSTR/MovingHorizonEstimator/Ipopt/Prediction form 0.16 ± 0.032 s 0.164 ± 0.032 s 0.979 ± 0.27
CASE STUDIES/StateEstimator/CSTR/MovingHorizonEstimator/OSQP/Current form 0.034 ± 0.0045 s 0.0322 ± 0.0042 s 1.06 ± 0.2
CASE STUDIES/StateEstimator/CSTR/MovingHorizonEstimator/OSQP/Prediction form 27 ± 4.5 ms 27 ± 5.8 ms 0.997 ± 0.27
CASE STUDIES/StateEstimator/Pendulum/MovingHorizonEstimator/Ipopt/Current form 0.0821 ± 0.0022 s 0.0842 ± 0.0025 s 0.975 ± 0.039
CASE STUDIES/StateEstimator/Pendulum/MovingHorizonEstimator/Ipopt/Current form (Hessian) 0.079 ± 0.0015 s 0.0816 ± 0.0021 s 0.968 ± 0.031
CASE STUDIES/StateEstimator/Pendulum/MovingHorizonEstimator/Ipopt/Prediction form 0.0639 ± 0.0023 s 0.0676 ± 0.004 s 0.945 ± 0.066
CASE STUDIES/StateEstimator/Pendulum/MovingHorizonEstimator/Ipopt/Prediction form (Hessian) 0.0817 ± 0.0022 s 0.0883 ± 0.0046 s 0.925 ± 0.054
CASE STUDIES/StateEstimator/Pendulum/MovingHorizonEstimator/MadNLP/Current form 3.64 ± 0.1 s 3.82 ± 0.06 s 0.953 ± 0.031
CASE STUDIES/StateEstimator/Pendulum/MovingHorizonEstimator/MadNLP/Prediction form 2.96 ± 0.085 s 2.96 ± 0.072 s 0.999 ± 0.038
UNIT TESTS/PredictiveController/ExplicitMPC/moveinput! 3.8 ± 0.03 μs 4.22 ± 0.03 μs 0.9 ± 0.0096
UNIT TESTS/PredictiveController/LinMPC/getinfo! 0.11 ± 0.0021 ms 0.111 ± 0.0035 ms 0.992 ± 0.036
UNIT TESTS/PredictiveController/LinMPC/moveinput!/MultipleShooting 0.107 ± 0.0015 ms 0.106 ± 0.0035 ms 1.01 ± 0.036
UNIT TESTS/PredictiveController/LinMPC/moveinput!/SingleShooting 16.5 ± 0.32 μs 16.9 ± 0.47 μs 0.975 ± 0.033
UNIT TESTS/PredictiveController/NonLinMPC/getinfo!/LinModel 0.199 ± 0.014 ms 0.213 ± 0.036 ms 0.931 ± 0.17
UNIT TESTS/PredictiveController/NonLinMPC/getinfo!/NonLinModel 0.234 ± 0.017 ms 0.241 ± 0.023 ms 0.971 ± 0.12
UNIT TESTS/PredictiveController/NonLinMPC/moveinput!/LinModel/MultipleShooting 2.57 ± 0.25 ms 2.59 ± 0.27 ms 0.991 ± 0.14
UNIT TESTS/PredictiveController/NonLinMPC/moveinput!/LinModel/SingleShooting 1.74 ± 0.066 ms 1.76 ± 0.092 ms 0.984 ± 0.063
UNIT TESTS/PredictiveController/NonLinMPC/moveinput!/NonLinModel/MultipleShooting 3.09 ± 0.11 ms 3.15 ± 0.17 ms 0.983 ± 0.064
UNIT TESTS/PredictiveController/NonLinMPC/moveinput!/NonLinModel/MultipleShootingHessian 3.11 ± 0.13 ms 3.19 ± 0.18 ms 0.974 ± 0.069
UNIT TESTS/PredictiveController/NonLinMPC/moveinput!/NonLinModel/SingleShooting 1.75 ± 0.055 ms 1.79 ± 0.091 ms 0.978 ± 0.058
UNIT TESTS/PredictiveController/NonLinMPC/moveinput!/NonLinModel/SingleShootingHessian 1.75 ± 0.051 ms 1.76 ± 0.062 ms 0.993 ± 0.045
UNIT TESTS/PredictiveController/NonLinMPC/moveinput!/NonLinModel/TrapezoidalCollocation 2.2 ± 0.054 ms 2.21 ± 0.071 ms 0.998 ± 0.04
UNIT TESTS/SimModel/LinModel/evaloutput 0.14 ± 0.001 μs 0.141 ± 0.01 μs 0.993 ± 0.071
UNIT TESTS/SimModel/LinModel/updatestate! 0.21 ± 0.001 μs 0.21 ± 0.01 μs 1 ± 0.048
UNIT TESTS/SimModel/NonLinModel/evaloutput 0.421 ± 0.01 μs 0.421 ± 0.01 μs 1 ± 0.034
UNIT TESTS/SimModel/NonLinModel/linearize! 2.07 ± 0.04 μs 2.04 ± 0.03 μs 1.02 ± 0.025
UNIT TESTS/SimModel/NonLinModel/updatestate! 0.491 ± 0.001 μs 0.481 ± 0.01 μs 1.02 ± 0.021
UNIT TESTS/StateEstimator/ExtendedKalmanFilter/evaloutput/LinModel 0.551 ± 0.01 μs 0.541 ± 0.009 μs 1.02 ± 0.025
UNIT TESTS/StateEstimator/ExtendedKalmanFilter/evaloutput/NonLinModel 1.81 ± 0.011 μs 1.82 ± 0.011 μs 0.995 ± 0.0085
UNIT TESTS/StateEstimator/ExtendedKalmanFilter/preparestate!/LinModel 0.27 ± 0.001 μs 0.27 ± 0.001 μs 1 ± 0.0052
UNIT TESTS/StateEstimator/ExtendedKalmanFilter/preparestate!/NonLinModel 1.41 ± 0.01 μs 1.41 ± 0.01 μs 0.999 ± 0.01
UNIT TESTS/StateEstimator/ExtendedKalmanFilter/updatestate!/LinModel 4.19 ± 0.07 μs 4.01 ± 0.051 μs 1.04 ± 0.022
UNIT TESTS/StateEstimator/ExtendedKalmanFilter/updatestate!/NonLinModel 8.82 ± 0.099 μs 9.24 ± 0.18 μs 0.955 ± 0.021
UNIT TESTS/StateEstimator/InternalModel/evaloutput/LinModel 0.231 ± 0.01 μs 0.231 ± 0.01 μs 1 ± 0.061
UNIT TESTS/StateEstimator/InternalModel/evaloutput/NonLinModel 0.582 ± 0.01 μs 0.571 ± 0.001 μs 1.02 ± 0.018
UNIT TESTS/StateEstimator/InternalModel/preparestate!/LinModel 0.281 ± 0.001 μs 0.321 ± 0.011 μs 0.875 ± 0.03
UNIT TESTS/StateEstimator/InternalModel/preparestate!/NonLinModel 0.731 ± 0.001 μs 0.742 ± 0.01 μs 0.985 ± 0.013
UNIT TESTS/StateEstimator/InternalModel/updatestate!/LinModel 0.42 ± 0.01 μs 0.441 ± 0.01 μs 0.952 ± 0.031
UNIT TESTS/StateEstimator/InternalModel/updatestate!/NonLinModel 0.912 ± 0.001 μs 1.2 ± 0.001 μs 0.759 ± 0.001
UNIT TESTS/StateEstimator/KalmanFilter/evaloutput 0.27 ± 0.01 μs 0.261 ± 0.01 μs 1.03 ± 0.055
UNIT TESTS/StateEstimator/KalmanFilter/preparestate! 0.131 ± 0.01 μs 0.14 ± 0.009 μs 0.936 ± 0.093
UNIT TESTS/StateEstimator/KalmanFilter/updatestate! 2.52 ± 0.03 μs 2.5 ± 0.03 μs 1 ± 0.017
UNIT TESTS/StateEstimator/Luenberger/evaloutput 0.27 ± 0.01 μs 0.24 ± 0.001 μs 1.12 ± 0.042
UNIT TESTS/StateEstimator/Luenberger/preparestate! 0.26 ± 0.01 μs 0.26 ± 0.001 μs 1 ± 0.039
UNIT TESTS/StateEstimator/Luenberger/updatestate! 0.341 ± 0.01 μs 0.35 ± 0.01 μs 0.974 ± 0.04
UNIT TESTS/StateEstimator/MovingHorizonEstimator/getinfo!/LinModel 0.188 ± 0.018 ms 0.234 ± 0.06 ms 0.806 ± 0.22
UNIT TESTS/StateEstimator/MovingHorizonEstimator/getinfo!/NonLinModel 0.346 ± 0.019 ms 0.363 ± 0.021 ms 0.955 ± 0.075
UNIT TESTS/StateEstimator/MovingHorizonEstimator/preparestate!/LinModel/Current form 3.35 ± 0.13 ms 3.43 ± 0.17 ms 0.977 ± 0.063
UNIT TESTS/StateEstimator/MovingHorizonEstimator/preparestate!/LinModel/Prediction form 0.481 ± 0.009 μs 0.481 ± 0 μs 1 ± 0.019
UNIT TESTS/StateEstimator/MovingHorizonEstimator/preparestate!/NonLinModel/Current form 0.321 ± 0.019 ms 0.339 ± 0.02 ms 0.948 ± 0.078
UNIT TESTS/StateEstimator/MovingHorizonEstimator/preparestate!/NonLinModel/Prediction form 1.32 ± 0.019 μs 1.33 ± 0.01 μs 0.993 ± 0.016
UNIT TESTS/StateEstimator/MovingHorizonEstimator/updatestate!/LinModel/Current form 6.49 ± 2.3 μs 13.8 ± 7.5 μs 0.47 ± 0.3
UNIT TESTS/StateEstimator/MovingHorizonEstimator/updatestate!/LinModel/Prediction form 2.95 ± 0.16 ms 3.19 ± 0.27 ms 0.925 ± 0.094
UNIT TESTS/StateEstimator/MovingHorizonEstimator/updatestate!/NonLinModel/Current form 16.8 ± 0.2 μs 17 ± 0.4 μs 0.988 ± 0.026
UNIT TESTS/StateEstimator/MovingHorizonEstimator/updatestate!/NonLinModel/Prediction form 0.336 ± 0.019 ms 0.344 ± 0.02 ms 0.977 ± 0.079
UNIT TESTS/StateEstimator/SteadyKalmanFilter/evaloutput 0.261 ± 0.011 μs 0.27 ± 0.01 μs 0.967 ± 0.054
UNIT TESTS/StateEstimator/SteadyKalmanFilter/preparestate! 0.29 ± 0.01 μs 0.29 ± 0.001 μs 1 ± 0.035
UNIT TESTS/StateEstimator/SteadyKalmanFilter/updatestate! 0.371 ± 0.001 μs 0.381 ± 0.01 μs 0.974 ± 0.026
UNIT TESTS/StateEstimator/UnscentedKalmanFilter/evaloutput/LinModel 0.301 ± 0.001 μs 0.301 ± 0.001 μs 1 ± 0.0047
UNIT TESTS/StateEstimator/UnscentedKalmanFilter/evaloutput/NonLinModel 0.912 ± 0.011 μs 0.912 ± 0.011 μs 1 ± 0.017
UNIT TESTS/StateEstimator/UnscentedKalmanFilter/preparestate!/LinModel 3.69 ± 0.031 μs 3.73 ± 0.04 μs 0.989 ± 0.013
UNIT TESTS/StateEstimator/UnscentedKalmanFilter/preparestate!/NonLinModel 4.92 ± 0.031 μs 4.9 ± 0.031 μs 1 ± 0.009
UNIT TESTS/StateEstimator/UnscentedKalmanFilter/updatestate!/LinModel 3.48 ± 0.031 μs 3.47 ± 0.03 μs 1 ± 0.012
UNIT TESTS/StateEstimator/UnscentedKalmanFilter/updatestate!/NonLinModel 6.35 ± 0.059 μs 6.33 ± 0.09 μs 1 ± 0.017
time_to_load 5.52 ± 0.0075 s 6.07 ± 0.2 s 0.91 ± 0.03
Memory benchmarks
main 0ac337c... main / 0ac337c...
CASE STUDIES/PredictiveController/CSTR/LinMPC/With feedforward/DAQP/SingleShooting 0.0424 M allocs: 1.71 MB 0.0424 M allocs: 1.71 MB 1
CASE STUDIES/PredictiveController/CSTR/LinMPC/With feedforward/Ipopt/MultipleShooting 0.162 M allocs: 8.9 MB 0.162 M allocs: 8.9 MB 1
CASE STUDIES/PredictiveController/CSTR/LinMPC/With feedforward/Ipopt/SingleShooting 0.0536 M allocs: 2.38 MB 0.0536 M allocs: 2.38 MB 1
CASE STUDIES/PredictiveController/CSTR/LinMPC/With feedforward/OSQP/MultipleShooting 0.0758 M allocs: 1.95 MB 0.0758 M allocs: 1.95 MB 1
CASE STUDIES/PredictiveController/CSTR/LinMPC/With feedforward/OSQP/SingleShooting 7.85 k allocs: 0.249 MB 7.85 k allocs: 0.249 MB 1
CASE STUDIES/PredictiveController/CSTR/LinMPC/Without feedforward/DAQP/SingleShooting 0.0423 M allocs: 1.7 MB 0.0423 M allocs: 1.7 MB 1
CASE STUDIES/PredictiveController/CSTR/LinMPC/Without feedforward/Ipopt/MultipleShooting 0.127 M allocs: 7.07 MB 0.127 M allocs: 7.07 MB 1
CASE STUDIES/PredictiveController/CSTR/LinMPC/Without feedforward/Ipopt/SingleShooting 0.0553 M allocs: 2.42 MB 0.0553 M allocs: 2.42 MB 1
CASE STUDIES/PredictiveController/CSTR/LinMPC/Without feedforward/OSQP/MultipleShooting 0.0532 M allocs: 1.39 MB 0.0532 M allocs: 1.39 MB 1
CASE STUDIES/PredictiveController/CSTR/LinMPC/Without feedforward/OSQP/SingleShooting 7.7 k allocs: 0.243 MB 7.7 k allocs: 0.243 MB 1
CASE STUDIES/PredictiveController/Pendulum/LinMPC/Successive linearization/DAQP/SingleShooting 0.115 M allocs: 6.25 MB 0.114 M allocs: 6.25 MB 1
CASE STUDIES/PredictiveController/Pendulum/LinMPC/Successive linearization/Ipopt/MultipleShooting 4.65 M allocs: 0.251 GB 4.65 M allocs: 0.251 GB 1
CASE STUDIES/PredictiveController/Pendulum/LinMPC/Successive linearization/Ipopt/SingleShooting 0.115 M allocs: 6.67 MB 0.115 M allocs: 6.67 MB 1
CASE STUDIES/PredictiveController/Pendulum/LinMPC/Successive linearization/OSQP/MultipleShooting 4.69 M allocs: 0.255 GB 4.69 M allocs: 0.255 GB 1
CASE STUDIES/PredictiveController/Pendulum/LinMPC/Successive linearization/OSQP/SingleShooting 0.126 M allocs: 7.8 MB 0.126 M allocs: 7.8 MB 1
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Custom constraints/Ipopt/MultipleShooting 0.351 M allocs: 19.7 MB 0.351 M allocs: 19.7 MB 1
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Custom constraints/Ipopt/MultipleShooting (Hessian) 0.862 M allocs: 0.0792 GB 0.862 M allocs: 0.0793 GB 0.999
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Custom constraints/Ipopt/SingleShooting 0.353 M allocs: 16.7 MB 0.353 M allocs: 16.7 MB 1
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Custom constraints/Ipopt/TrapezoidalCollocation 1.01 M allocs: 0.0715 GB 1.01 M allocs: 0.0715 GB 0.999
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Custom constraints/Ipopt/TrapezoidalCollocation (Hessian) 1.01 M allocs: 0.0715 GB 1.01 M allocs: 0.0715 GB 0.999
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Economic/Ipopt/MultipleShooting 0.267 M allocs: 14.7 MB 0.267 M allocs: 14.7 MB 1
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Economic/Ipopt/MultipleShooting (Hessian) 0.633 M allocs: 0.0604 GB 0.633 M allocs: 0.0604 GB 0.999
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Economic/Ipopt/SingleShooting 0.0951 M allocs: 3.9 MB 0.0951 M allocs: 3.9 MB 1
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Economic/Ipopt/SingleShooting (Hessian) 0.0772 M allocs: 5.08 MB 0.0772 M allocs: 5.11 MB 0.994
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Economic/Ipopt/TrapezoidalCollocation 0.321 M allocs: 17.1 MB 0.321 M allocs: 17.1 MB 1
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Economic/Ipopt/TrapezoidalCollocation (Hessian) 0.913 M allocs: 0.0727 GB 0.913 M allocs: 0.0727 GB 0.999
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Economic/MadNLP/SingleShooting 5.82 M allocs: 1.13 GB 5.82 M allocs: 1.14 GB 0.989
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/Ipopt/MultipleShooting 0.226 M allocs: 12.2 MB 0.226 M allocs: 12.2 MB 1
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/Ipopt/MultipleShooting (Hessian) 0.647 M allocs: 0.0543 GB 0.647 M allocs: 0.0544 GB 0.999
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/Ipopt/MultipleShooting (threaded) 0.244 M allocs: 20.7 MB 0.244 M allocs: 21 MB 0.985
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/Ipopt/SingleShooting 0.0741 M allocs: 3 MB 0.0741 M allocs: 3 MB 1
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/Ipopt/SingleShooting (Hessian) 0.0768 M allocs: 5.04 MB 0.0768 M allocs: 5.07 MB 0.994
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/Ipopt/TrapezoidalCollocation 0.271 M allocs: 14.3 MB 0.271 M allocs: 14.3 MB 1
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/Ipopt/TrapezoidalCollocation (Hessian) 0.761 M allocs: 0.0496 GB 0.761 M allocs: 0.0496 GB 0.999
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/Ipopt/TrapezoidalCollocation (threaded) 0.289 M allocs: 22.9 MB 0.289 M allocs: 23.2 MB 0.986
CASE STUDIES/PredictiveController/Pendulum/NonLinMPC/Noneconomic/MadNLP/SingleShooting 8.15 M allocs: 1.58 GB 8.15 M allocs: 1.6 GB 0.99
CASE STUDIES/StateEstimator/CSTR/MovingHorizonEstimator/DAQP/Current form 0.762 M allocs: 0.0802 GB 0.762 M allocs: 0.0802 GB 1
CASE STUDIES/StateEstimator/CSTR/MovingHorizonEstimator/DAQP/Prediction form 0.682 M allocs: 0.0585 GB 0.682 M allocs: 0.0585 GB 1
CASE STUDIES/StateEstimator/CSTR/MovingHorizonEstimator/Ipopt/Current form 0.646 M allocs: 0.0785 GB 0.646 M allocs: 0.0785 GB 1
CASE STUDIES/StateEstimator/CSTR/MovingHorizonEstimator/Ipopt/Prediction form 0.601 M allocs: 0.0562 GB 0.601 M allocs: 0.0562 GB 1
CASE STUDIES/StateEstimator/CSTR/MovingHorizonEstimator/OSQP/Current form 0.63 M allocs: 0.0764 GB 0.63 M allocs: 0.0764 GB 1
CASE STUDIES/StateEstimator/CSTR/MovingHorizonEstimator/OSQP/Prediction form 0.585 M allocs: 0.0553 GB 0.585 M allocs: 0.0553 GB 1
CASE STUDIES/StateEstimator/Pendulum/MovingHorizonEstimator/Ipopt/Current form 0.0649 M allocs: 11.5 MB 0.0649 M allocs: 11.5 MB 1
CASE STUDIES/StateEstimator/Pendulum/MovingHorizonEstimator/Ipopt/Current form (Hessian) 0.0639 M allocs: 11.3 MB 0.0639 M allocs: 11.3 MB 1
CASE STUDIES/StateEstimator/Pendulum/MovingHorizonEstimator/Ipopt/Prediction form 0.0485 M allocs: 8.05 MB 0.0485 M allocs: 8.05 MB 1
CASE STUDIES/StateEstimator/Pendulum/MovingHorizonEstimator/Ipopt/Prediction form (Hessian) 0.0642 M allocs: 11.3 MB 0.0642 M allocs: 11.3 MB 1
CASE STUDIES/StateEstimator/Pendulum/MovingHorizonEstimator/MadNLP/Current form 13.8 M allocs: 2.46 GB 13.8 M allocs: 2.46 GB 1
CASE STUDIES/StateEstimator/Pendulum/MovingHorizonEstimator/MadNLP/Prediction form 11.2 M allocs: 2 GB 11.2 M allocs: 2 GB 1
UNIT TESTS/PredictiveController/ExplicitMPC/moveinput! 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/PredictiveController/LinMPC/getinfo! 0.323 k allocs: 15.6 kB 0.323 k allocs: 15.6 kB 1
UNIT TESTS/PredictiveController/LinMPC/moveinput!/MultipleShooting 0.994 k allocs: 25.5 kB 0.994 k allocs: 25.5 kB 1
UNIT TESTS/PredictiveController/LinMPC/moveinput!/SingleShooting 0.088 k allocs: 2.23 kB 0.088 k allocs: 2.23 kB 1
UNIT TESTS/PredictiveController/NonLinMPC/getinfo!/LinModel 0.563 k allocs: 0.0588 MB 0.563 k allocs: 0.0589 MB 0.998
UNIT TESTS/PredictiveController/NonLinMPC/getinfo!/NonLinModel 0.606 k allocs: 0.0776 MB 0.606 k allocs: 0.0779 MB 0.996
UNIT TESTS/PredictiveController/NonLinMPC/moveinput!/LinModel/MultipleShooting 2.4 k allocs: 0.107 MB 2.4 k allocs: 0.107 MB 1
UNIT TESTS/PredictiveController/NonLinMPC/moveinput!/LinModel/SingleShooting 0.37 k allocs: 13.1 kB 0.37 k allocs: 13.1 kB 1
UNIT TESTS/PredictiveController/NonLinMPC/moveinput!/NonLinModel/MultipleShooting 2.64 k allocs: 0.126 MB 2.64 k allocs: 0.126 MB 1
UNIT TESTS/PredictiveController/NonLinMPC/moveinput!/NonLinModel/MultipleShootingHessian 3.15 k allocs: 0.158 MB 3.15 k allocs: 0.158 MB 1
UNIT TESTS/PredictiveController/NonLinMPC/moveinput!/NonLinModel/SingleShooting 0.404 k allocs: 14.7 kB 0.404 k allocs: 14.7 kB 1
UNIT TESTS/PredictiveController/NonLinMPC/moveinput!/NonLinModel/SingleShootingHessian 0.404 k allocs: 14.7 kB 0.404 k allocs: 14.7 kB 1
UNIT TESTS/PredictiveController/NonLinMPC/moveinput!/NonLinModel/TrapezoidalCollocation 1.92 k allocs: 0.0816 MB 1.92 k allocs: 0.0816 MB 1
UNIT TESTS/SimModel/LinModel/evaloutput 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/SimModel/LinModel/updatestate! 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/SimModel/NonLinModel/evaloutput 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/SimModel/NonLinModel/linearize! 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/SimModel/NonLinModel/updatestate! 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/ExtendedKalmanFilter/evaloutput/LinModel 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/ExtendedKalmanFilter/evaloutput/NonLinModel 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/ExtendedKalmanFilter/preparestate!/LinModel 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/ExtendedKalmanFilter/preparestate!/NonLinModel 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/ExtendedKalmanFilter/updatestate!/LinModel 4 allocs: 0.0938 kB 4 allocs: 0.0938 kB 1
UNIT TESTS/StateEstimator/ExtendedKalmanFilter/updatestate!/NonLinModel 4 allocs: 0.0938 kB 4 allocs: 0.0938 kB 1
UNIT TESTS/StateEstimator/InternalModel/evaloutput/LinModel 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/InternalModel/evaloutput/NonLinModel 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/InternalModel/preparestate!/LinModel 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/InternalModel/preparestate!/NonLinModel 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/InternalModel/updatestate!/LinModel 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/InternalModel/updatestate!/NonLinModel 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/KalmanFilter/evaloutput 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/KalmanFilter/preparestate! 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/KalmanFilter/updatestate! 4 allocs: 0.0938 kB 4 allocs: 0.0938 kB 1
UNIT TESTS/StateEstimator/Luenberger/evaloutput 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/Luenberger/preparestate! 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/Luenberger/updatestate! 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/MovingHorizonEstimator/getinfo!/LinModel 1.03 k allocs: 0.0393 MB 1.03 k allocs: 0.0393 MB 1
UNIT TESTS/StateEstimator/MovingHorizonEstimator/getinfo!/NonLinModel 1.24 k allocs: 0.203 MB 1.24 k allocs: 0.203 MB 1
UNIT TESTS/StateEstimator/MovingHorizonEstimator/preparestate!/LinModel/Current form 0.0754 M allocs: 14.6 MB 0.0754 M allocs: 14.6 MB 0.999
UNIT TESTS/StateEstimator/MovingHorizonEstimator/preparestate!/LinModel/Prediction form 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/MovingHorizonEstimator/preparestate!/NonLinModel/Current form 0.972 k allocs: 25.4 kB 0.972 k allocs: 25.4 kB 1
UNIT TESTS/StateEstimator/MovingHorizonEstimator/preparestate!/NonLinModel/Prediction form 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/MovingHorizonEstimator/updatestate!/LinModel/Current form 2 allocs: 0.0469 kB 2 allocs: 0.0469 kB 1
UNIT TESTS/StateEstimator/MovingHorizonEstimator/updatestate!/LinModel/Prediction form 7.05 k allocs: 0.443 MB 7.05 k allocs: 0.443 MB 1
UNIT TESTS/StateEstimator/MovingHorizonEstimator/updatestate!/NonLinModel/Current form 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/MovingHorizonEstimator/updatestate!/NonLinModel/Prediction form 0.972 k allocs: 25.4 kB 0.972 k allocs: 25.4 kB 1
UNIT TESTS/StateEstimator/SteadyKalmanFilter/evaloutput 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/SteadyKalmanFilter/preparestate! 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/SteadyKalmanFilter/updatestate! 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/UnscentedKalmanFilter/evaloutput/LinModel 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/UnscentedKalmanFilter/evaloutput/NonLinModel 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/UnscentedKalmanFilter/preparestate!/LinModel 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/UnscentedKalmanFilter/preparestate!/NonLinModel 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/UnscentedKalmanFilter/updatestate!/LinModel 0 allocs: 0 B 0 allocs: 0 B
UNIT TESTS/StateEstimator/UnscentedKalmanFilter/updatestate!/NonLinModel 0 allocs: 0 B 0 allocs: 0 B
time_to_load 0.149 k allocs: 11.2 kB 0.149 k allocs: 11.2 kB 1

The option was ignore since `hessian=true` meants sparse `AutoForwardDiff`, meaning that it was bypassing the other backends for efficiency (a `@warn` was printed to mention this)
@franckgaga
Copy link
Member Author

franckgaga commented Mar 3, 2026

I no longer have the numerics details in my head, but something I do know tend to be important is numerical scaling by the "typical magnitude" of the variables. A nice benefit of these methods is that they can be made to work for DAEs relatively easily

Yes, right. For now I do not support any scaling factors at all throughout the package. My experience is that most of the time it's possible to "re-scale" the states/outputs/inputs/etc. manually by modifying the f! and h! function, and it's generally a better idea than using the scaling factors available in optimization and nonlinear solver packages, since you have the full control on how you want to do it (e.g. linear or not, offset or not, etc.). And since you did it yourself, there is no weird surprised on the effect of the various parameters e.g. the covariance matrices in the kalman filter, etc.

@franckgaga franckgaga merged commit 6ca5bd4 into main Mar 3, 2026
5 of 6 checks passed
@franckgaga franckgaga deleted the orthogonal_colloc branch March 3, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New transcription method based on orthogonal collocation

3 participants